package cn.tedu.fwmk.detail.controller;

import cn.tedu.common.vo.JsonResult;
import cn.tedu.fwmk.detail.pojo.dto.DetailParam;
import cn.tedu.fwmk.detail.pojo.dto.DetailQuery;
import cn.tedu.fwmk.detail.pojo.vo.DetailVO;
import cn.tedu.fwmk.detail.service.DetailService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.xml.soap.Detail;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/ry/detail")
public class DetailController {
    @Autowired
    DetailService detailService;

    @PostMapping("insert")
    @ApiOperation(value = "详情服务模块增加")
    public JsonResult insertDetail(@RequestBody DetailParam detailParam) {
        log.debug("增加服务模块：insertDetail={}", detailParam);
        detailService.insertDetail(detailParam);
        return JsonResult.ok("添加成功");

    }

    @PostMapping("delete/{serviceId}")
    @ApiOperation(value = "详情服务模块删除")
    public JsonResult deleteDetail(@PathVariable Long serviceId) {
        log.debug("删除服务模块：deleteDetail={}", serviceId);
        detailService.deleteDetail(serviceId);
        return JsonResult.ok("删除成功");
    }

    @GetMapping("select")
    @ApiOperation(value = "查询搜索栏关键字")
    public JsonResult selectSearchbar(DetailQuery detailQuery) {
        log.debug("查询搜索栏关键字：selectSearchbar={}", detailQuery);
        List<DetailVO> list = detailService.selectSearchbar(detailQuery);
        return JsonResult.ok(list);

    }
}
